package com.zlp.utils.hashcode;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: zhulaiping
 * @Date: 2021/11/3 14:16
 */
public class HashCodeClass {

    private String str0;
    private double dou0;
    private int       int0;

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof HashCodeClass) {
            HashCodeClass hcc = (HashCodeClass)obj;
            if (hcc.str0.equals(this.str0) &&
                    hcc.dou0 == this.dou0 &&
                    hcc.int0 == this.int0) {
                return true;
            }
            return false;
        }
        return false;
    }
    public static void main(String[] args) {
        HashCodeClass h1 = new HashCodeClass();
        HashCodeClass h2 = new HashCodeClass();
        HashCodeClass h3 = new HashCodeClass();
        HashCodeClass h4 = new HashCodeClass();
        System.out.println(h1.hashCode());
        System.out.println(h2.hashCode());
        System.out.println(h3.hashCode());
        System.out.println(h4.hashCode());
        Set<HashCodeClass> set = new HashSet<>();
        set.add(h1);
        set.add(h2);
        set.add(h3);
        set.add(h4);
        System.out.println(set.size());
    }

}
